(function(a, ng) {
    'use strict';
    var app = a.adminApp;

    app.factory('SessionService', function($resource) {

    });

    var helpers = {};

    app
            .factory(
                    'Helpers',
                    function() {
                        var str_pad = function(e, t, n, r) {
                            var i = "", s, e = e;
                            var o = function(e, t) {
                                var n = "", r, e = e;
                                while (n.length < t) {
                                    n += e
                                }
                                n = n.substr(0, t);
                                return n
                            };
                            e += "";
                            n = n !== undefined ? n : " ";
                            if (r !== "STR_PAD_LEFT" && r !== "STR_PAD_RIGHT"
                                    && r !== "STR_PAD_BOTH") {
                                r = "STR_PAD_RIGHT"
                            }
                            if ((s = t - e.length) > 0) {
                                if (r === "STR_PAD_LEFT") {
                                    e = o(n, s) + e
                                } else if (r === "STR_PAD_RIGHT") {
                                    e = e + o(n, s)
                                } else if (r === "STR_PAD_BOTH") {
                                    i = o(n, Math.ceil(s / 2));
                                    e = i + e + i;
                                    e = e.substr(0, t)
                                }
                            }
                            return e;
                        };

                        return {
                            extract: function(str, type) {

                                var patternUS = /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/gi, patternBR = /[0-9]{4}\/[0-9]{2}\/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/gi, dateExplode, date = str;
                                var type = type || 'date';
                                switch (type) {

                                    case 'date':
                                    case 'default':
                                        if (patternUS.test(str)) {
                                            dateExplode = str.split(" ");
                                            return dateExplode[0];
                                        }
                                        break;
                                    case 'time':
                                        if (patternUS.test(str)
                                                || patternBR.test(str)) {
                                            dateExplode = str.split(" ");
                                            dateExplode = dateExplode[1].split(':');

                                            return dateExplode[0] + ':'
                                                    + dateExplode[1];
                                        }

                                        break;

                                }

                                return str;

                            },
                            str_pad: str_pad
                        };

                    });

    app.factory('fLoading', function() {

        return {
            toggle: function() {

            }
        };
    });

    app
            .factory(
                    'cocFileUploader',
                    [
                        '$rootScope',
                        '$q',
                        function($rootScope, $q) {

                            var upl = {
                                post: function(files, data, progressTarget) {
                                    return {
                                        to: (function(urlPost) {
                                            var deferred = $q.defer();
                                            if (!files || !files.length) {
                                                deferred
                                                        .reject('Sem arquivos para envio');
                                                return;
                                            }
                                            var xhr = new XMLHttpRequest();
                                            xhr.upload.onprogress = function(
                                                    e) {
                                                $rootScope
                                                        .$apply(function() {
                                                            var completeProgress;
                                                            if (e.lengthComputable) {
                                                                completeProgress = Math
                                                                        .round(e.loaded
                                                                                / e.total
                                                                                * 100);
                                                                if (progressTarget) {
                                                                    progressTarget(completeProgress);
                                                                } else if (deferred
                                                                        .notify()) {
                                                                    deferred
                                                                            .notify(completeProgress);
                                                                }
                                                            }
                                                        });
                                            };
                                            // finish upload file

                                            xhr.onload = function(e) {
                                                $rootScope
                                                        .$apply(function() {
                                                            var res = {
                                                                files: files,
                                                                data: ng
                                                                        .fromJson(xhr.responseText),
                                                                obj: xhr
                                                            };
                                                            deferred
                                                                    .resolve(res);
                                                        });
                                            };

                                            // error return

                                            xhr.upload.error = function(e) {
                                                var msg = xhr.responseText ? xhr.responseText
                                                        : "Ocorreu um erro no processo";
                                                $rootScope
                                                        .$apply(function() {
                                                            deferred
                                                                    .reject(msg);
                                                        });
                                            };

                                            // prepare data form
                                            var $formUpload = new FormData();
                                            if (data) {
                                                Object
                                                        .keys(data)
                                                        .forEach(
                                                                function(
                                                                        key) {
                                                                    $formUpload
                                                                            .append(
                                                                                    key,
                                                                                    data[key]);
                                                                });
                                            }
                                            for (var indexUp = 0; indexUp < files.length; indexUp += 1) {
                                                $formUpload
                                                        .append(
                                                                files[indexUp].name,
                                                                files[indexUp]);
                                            }
                                            // start upload
                                            xhr.open('POST', urlPost);
                                            xhr.send($formUpload);
                                            //
                                            xhr.onreadystatechange = function(
                                                    e) {
                                                if (4 == this.readyState
                                                        && this.status != 200) {
                                                    var msg = this.responseText ? this.responseText
                                                            : "Ocorreu um erro no processo";
                                                    $rootScope.$emit(
                                                            'errorUpload',
                                                            msg);

                                                }
                                            };

                                            return deferred.promise;

                                        })
                                    };

                                }
                            };
                            return upl;
                        }]);

    app
            .factory(
                    'hashGen',
                    [function() {

                            function SHA512(e) {
                                function t(e, t) {
                                    this.highOrder = e;
                                    this.lowOrder = t
                                }
                                ;
                                function y(e) {
                                    return unescape(encodeURIComponent(e))
                                }
                                function b(e) {
                                    var t = [];
                                    var n = (1 << g) - 1;
                                    var r = e.length * g;
                                    for (var i = 0; i < r; i += g) {
                                        t[i >> 5] |= (e.charCodeAt(i / g) & n) << 32
                                                - g - i % 32
                                    }
                                    return t
                                }
                                function w(e) {
                                    var t = "0123456789abcdef";
                                    var n = "";
                                    var r = e.length * 4;
                                    var i;
                                    for (var s = 0; s < r; s += 1) {
                                        i = e[s >> 2] >> (3 - s % 4) * 8;
                                        n += t.charAt(i >> 4 & 15)
                                                + t.charAt(i & 15)
                                    }
                                    return n
                                }
                                function E(e, n) {
                                    var r, i, s, o;
                                    r = (e.lowOrder & 65535) + (n.lowOrder & 65535);
                                    i = (e.lowOrder >>> 16) + (n.lowOrder >>> 16)
                                            + (r >>> 16);
                                    s = (i & 65535) << 16 | r & 65535;
                                    r = (e.highOrder & 65535)
                                            + (n.highOrder & 65535) + (i >>> 16);
                                    i = (e.highOrder >>> 16) + (n.highOrder >>> 16)
                                            + (r >>> 16);
                                    o = (i & 65535) << 16 | r & 65535;
                                    return new t(o, s)
                                }
                                function S(e, n, r, i) {
                                    var s, o, u, a;
                                    s = (e.lowOrder & 65535) + (n.lowOrder & 65535)
                                            + (r.lowOrder & 65535)
                                            + (i.lowOrder & 65535);
                                    o = (e.lowOrder >>> 16) + (n.lowOrder >>> 16)
                                            + (r.lowOrder >>> 16)
                                            + (i.lowOrder >>> 16) + (s >>> 16);
                                    u = (o & 65535) << 16 | s & 65535;
                                    s = (e.highOrder & 65535)
                                            + (n.highOrder & 65535)
                                            + (r.highOrder & 65535)
                                            + (i.highOrder & 65535) + (o >>> 16);
                                    o = (e.highOrder >>> 16) + (n.highOrder >>> 16)
                                            + (r.highOrder >>> 16)
                                            + (i.highOrder >>> 16) + (s >>> 16);
                                    a = (o & 65535) << 16 | s & 65535;
                                    return new t(a, u)
                                }
                                function x(e, n, r, i, s) {
                                    var o, u, a, f;
                                    o = (e.lowOrder & 65535) + (n.lowOrder & 65535)
                                            + (r.lowOrder & 65535)
                                            + (i.lowOrder & 65535)
                                            + (s.lowOrder & 65535);
                                    u = (e.lowOrder >>> 16) + (n.lowOrder >>> 16)
                                            + (r.lowOrder >>> 16)
                                            + (i.lowOrder >>> 16)
                                            + (s.lowOrder >>> 16) + (o >>> 16);
                                    a = (u & 65535) << 16 | o & 65535;
                                    o = (e.highOrder & 65535)
                                            + (n.highOrder & 65535)
                                            + (r.highOrder & 65535)
                                            + (i.highOrder & 65535)
                                            + (s.highOrder & 65535) + (u >>> 16);
                                    u = (e.highOrder >>> 16) + (n.highOrder >>> 16)
                                            + (r.highOrder >>> 16)
                                            + (i.highOrder >>> 16)
                                            + (s.highOrder >>> 16) + (o >>> 16);
                                    f = (u & 65535) << 16 | o & 65535;
                                    return new t(f, a)
                                }
                                function T(e, n, r) {
                                    return new t(e.highOrder & n.highOrder
                                            ^ e.highOrder & r.highOrder
                                            ^ n.highOrder & r.highOrder, e.lowOrder
                                            & n.lowOrder ^ e.lowOrder & r.lowOrder
                                            ^ n.lowOrder & r.lowOrder)
                                }
                                function N(e, n, r) {
                                    return new t(e.highOrder & n.highOrder
                                            ^ ~e.highOrder & r.highOrder,
                                            e.lowOrder & n.lowOrder ^ ~e.lowOrder
                                            & r.lowOrder)
                                }
                                function C(e, n) {
                                    if (n <= 32) {
                                        return new t(e.highOrder >>> n
                                                | e.lowOrder << 32 - n,
                                                e.lowOrder >>> n
                                                | e.highOrder << 32 - n)
                                    } else {
                                        return new t(e.lowOrder >>> n
                                                | e.highOrder << 32 - n,
                                                e.highOrder >>> n
                                                | e.lowOrder << 32 - n)
                                    }
                                }
                                function k(e) {
                                    var n = C(e, 28);
                                    var r = C(e, 34);
                                    var i = C(e, 39);
                                    return new t(n.highOrder ^ r.highOrder
                                            ^ i.highOrder, n.lowOrder ^ r.lowOrder
                                            ^ i.lowOrder)
                                }
                                function L(e) {
                                    var n = C(e, 14);
                                    var r = C(e, 18);
                                    var i = C(e, 41);
                                    return new t(n.highOrder ^ r.highOrder
                                            ^ i.highOrder, n.lowOrder ^ r.lowOrder
                                            ^ i.lowOrder)
                                }
                                function A(e) {
                                    var n = C(e, 1), r = C(e, 8), i = M(e, 7);
                                    return new t(n.highOrder ^ r.highOrder
                                            ^ i.highOrder, n.lowOrder ^ r.lowOrder
                                            ^ i.lowOrder)
                                }
                                function O(e) {
                                    var n = C(e, 19);
                                    var r = C(e, 61);
                                    var i = M(e, 6);
                                    return new t(n.highOrder ^ r.highOrder
                                            ^ i.highOrder, n.lowOrder ^ r.lowOrder
                                            ^ i.lowOrder)
                                }
                                function M(e, n) {
                                    if (n <= 32) {
                                        return new t(e.highOrder >>> n,
                                                e.lowOrder >>> n
                                                | e.highOrder << 32 - n)
                                    } else {
                                        return new t(0, e.highOrder << 32 - n)
                                    }
                                }
                                var n = [new t(1779033703, 4089235720),
                                    new t(3144134277, 2227873595),
                                    new t(1013904242, 4271175723),
                                    new t(2773480762, 1595750129),
                                    new t(1359893119, 2917565137),
                                    new t(2600822924, 725511199),
                                    new t(528734635, 4215389547),
                                    new t(1541459225, 327033209)];
                                var r = [new t(1116352408, 3609767458),
                                    new t(1899447441, 602891725),
                                    new t(3049323471, 3964484399),
                                    new t(3921009573, 2173295548),
                                    new t(961987163, 4081628472),
                                    new t(1508970993, 3053834265),
                                    new t(2453635748, 2937671579),
                                    new t(2870763221, 3664609560),
                                    new t(3624381080, 2734883394),
                                    new t(310598401, 1164996542),
                                    new t(607225278, 1323610764),
                                    new t(1426881987, 3590304994),
                                    new t(1925078388, 4068182383),
                                    new t(2162078206, 991336113),
                                    new t(2614888103, 633803317),
                                    new t(3248222580, 3479774868),
                                    new t(3835390401, 2666613458),
                                    new t(4022224774, 944711139),
                                    new t(264347078, 2341262773),
                                    new t(604807628, 2007800933),
                                    new t(770255983, 1495990901),
                                    new t(1249150122, 1856431235),
                                    new t(1555081692, 3175218132),
                                    new t(1996064986, 2198950837),
                                    new t(2554220882, 3999719339),
                                    new t(2821834349, 766784016),
                                    new t(2952996808, 2566594879),
                                    new t(3210313671, 3203337956),
                                    new t(3336571891, 1034457026),
                                    new t(3584528711, 2466948901),
                                    new t(113926993, 3758326383),
                                    new t(338241895, 168717936),
                                    new t(666307205, 1188179964),
                                    new t(773529912, 1546045734),
                                    new t(1294757372, 1522805485),
                                    new t(1396182291, 2643833823),
                                    new t(1695183700, 2343527390),
                                    new t(1986661051, 1014477480),
                                    new t(2177026350, 1206759142),
                                    new t(2456956037, 344077627),
                                    new t(2730485921, 1290863460),
                                    new t(2820302411, 3158454273),
                                    new t(3259730800, 3505952657),
                                    new t(3345764771, 106217008),
                                    new t(3516065817, 3606008344),
                                    new t(3600352804, 1432725776),
                                    new t(4094571909, 1467031594),
                                    new t(275423344, 851169720),
                                    new t(430227734, 3100823752),
                                    new t(506948616, 1363258195),
                                    new t(659060556, 3750685593),
                                    new t(883997877, 3785050280),
                                    new t(958139571, 3318307427),
                                    new t(1322822218, 3812723403),
                                    new t(1537002063, 2003034995),
                                    new t(1747873779, 3602036899),
                                    new t(1955562222, 1575990012),
                                    new t(2024104815, 1125592928),
                                    new t(2227730452, 2716904306),
                                    new t(2361852424, 442776044),
                                    new t(2428436474, 593698344),
                                    new t(2756734187, 3733110249),
                                    new t(3204031479, 2999351573),
                                    new t(3329325298, 3815920427),
                                    new t(3391569614, 3928383900),
                                    new t(3515267271, 566280711),
                                    new t(3940187606, 3454069534),
                                    new t(4118630271, 4000239992),
                                    new t(116418474, 1914138554),
                                    new t(174292421, 2731055270),
                                    new t(289380356, 3203993006),
                                    new t(460393269, 320620315),
                                    new t(685471733, 587496836),
                                    new t(852142971, 1086792851),
                                    new t(1017036298, 365543100),
                                    new t(1126000580, 2618297676),
                                    new t(1288033470, 3409855158),
                                    new t(1501505948, 4234509866),
                                    new t(1607167915, 987167468),
                                    new t(1816402316, 1246189591)];
                                var i = new Array(64);
                                var s, o, u, a, f, l, c, h, p, d;
                                var v, m;
                                var g = 8;
                                e = y(e);
                                var _ = e.length * g;
                                e = b(e);
                                e[_ >> 5] |= 128 << 24 - _ % 32;
                                e[(_ + 128 >> 10 << 5) + 31] = _;
                                for (var p = 0; p < e.length; p += 32) {
                                    s = n[0];
                                    o = n[1];
                                    u = n[2];
                                    a = n[3];
                                    f = n[4];
                                    l = n[5];
                                    c = n[6];
                                    h = n[7];
                                    for (var d = 0; d < 80; d++) {
                                        if (d < 16) {
                                            i[d] = new t(e[d * 2 + p], e[d * 2 + p
                                                    + 1])
                                        } else {
                                            i[d] = S(O(i[d - 2]), i[d - 7],
                                                    A(i[d - 15]), i[d - 16])
                                        }
                                        v = x(h, L(f), N(f, l, c), r[d], i[d]);
                                        m = E(k(s), T(s, o, u));
                                        h = c;
                                        c = l;
                                        l = f;
                                        f = E(a, v);
                                        a = u;
                                        u = o;
                                        o = s;
                                        s = E(v, m)
                                    }
                                    n[0] = E(s, n[0]);
                                    n[1] = E(o, n[1]);
                                    n[2] = E(u, n[2]);
                                    n[3] = E(a, n[3]);
                                    n[4] = E(f, n[4]);
                                    n[5] = E(l, n[5]);
                                    n[6] = E(c, n[6]);
                                    n[7] = E(h, n[7])
                                }
                                var D = [];
                                for (var p = 0; p < n.length; p++) {
                                    D.push(n[p].highOrder);
                                    D.push(n[p].lowOrder)
                                }
                                return w(D)
                            }
                            ;
                            function md5(e) {
                                var t;
                                var n = function(e, t) {
                                    return e << t | e >>> 32 - t
                                };
                                var r = function(e, t) {
                                    var n, r, i, s, o;
                                    i = e & 2147483648;
                                    s = t & 2147483648;
                                    n = e & 1073741824;
                                    r = t & 1073741824;
                                    o = (e & 1073741823) + (t & 1073741823);
                                    if (n & r) {
                                        return o ^ 2147483648 ^ i ^ s
                                    }
                                    if (n | r) {
                                        if (o & 1073741824) {
                                            return o ^ 3221225472 ^ i ^ s
                                        } else {
                                            return o ^ 1073741824 ^ i ^ s
                                        }
                                    } else {
                                        return o ^ i ^ s
                                    }
                                };
                                var i = function(e, t, n) {
                                    return e & t | ~e & n
                                };
                                var s = function(e, t, n) {
                                    return e & n | t & ~n
                                };
                                var o = function(e, t, n) {
                                    return e ^ t ^ n
                                };
                                var u = function(e, t, n) {
                                    return t ^ (e | ~n)
                                };
                                var a = function(e, t, s, o, u, a, f) {
                                    e = r(e, r(r(i(t, s, o), u), f));
                                    return r(n(e, a), t)
                                };
                                var f = function(e, t, i, o, u, a, f) {
                                    e = r(e, r(r(s(t, i, o), u), f));
                                    return r(n(e, a), t)
                                };
                                var l = function(e, t, i, s, u, a, f) {
                                    e = r(e, r(r(o(t, i, s), u), f));
                                    return r(n(e, a), t)
                                };
                                var c = function(e, t, i, s, o, a, f) {
                                    e = r(e, r(r(u(t, i, s), o), f));
                                    return r(n(e, a), t)
                                };
                                var h = function(e) {
                                    var t;
                                    var n = e.length;
                                    var r = n + 8;
                                    var i = (r - r % 64) / 64;
                                    var s = (i + 1) * 16;
                                    var o = new Array(s - 1);
                                    var u = 0;
                                    var a = 0;
                                    while (a < n) {
                                        t = (a - a % 4) / 4;
                                        u = a % 4 * 8;
                                        o[t] = o[t] | e.charCodeAt(a) << u;
                                        a++
                                    }
                                    t = (a - a % 4) / 4;
                                    u = a % 4 * 8;
                                    o[t] = o[t] | 128 << u;
                                    o[s - 2] = n << 3;
                                    o[s - 1] = n >>> 29;
                                    return o
                                };
                                var p = function(e) {
                                    var t = "", n = "", r, i;
                                    for (i = 0; i <= 3; i++) {
                                        r = e >>> i * 8 & 255;
                                        n = "0" + r.toString(16);
                                        t = t + n.substr(n.length - 2, 2)
                                    }
                                    return t
                                };
                                var d = [], v, m, g, y, b, w, E, S, x, T = 7, N = 12, C = 17, k = 22, L = 5, A = 9, O = 14, M = 20, _ = 4, D = 11, P = 16, H = 23, B = 6, j = 10, F = 15, I = 21;
                                e = this.utf8_encode(e);
                                d = h(e);
                                w = 1732584193;
                                E = 4023233417;
                                S = 2562383102;
                                x = 271733878;
                                t = d.length;
                                for (v = 0; v < t; v += 16) {
                                    m = w;
                                    g = E;
                                    y = S;
                                    b = x;
                                    w = a(w, E, S, x, d[v + 0], T, 3614090360);
                                    x = a(x, w, E, S, d[v + 1], N, 3905402710);
                                    S = a(S, x, w, E, d[v + 2], C, 606105819);
                                    E = a(E, S, x, w, d[v + 3], k, 3250441966);
                                    w = a(w, E, S, x, d[v + 4], T, 4118548399);
                                    x = a(x, w, E, S, d[v + 5], N, 1200080426);
                                    S = a(S, x, w, E, d[v + 6], C, 2821735955);
                                    E = a(E, S, x, w, d[v + 7], k, 4249261313);
                                    w = a(w, E, S, x, d[v + 8], T, 1770035416);
                                    x = a(x, w, E, S, d[v + 9], N, 2336552879);
                                    S = a(S, x, w, E, d[v + 10], C, 4294925233);
                                    E = a(E, S, x, w, d[v + 11], k, 2304563134);
                                    w = a(w, E, S, x, d[v + 12], T, 1804603682);
                                    x = a(x, w, E, S, d[v + 13], N, 4254626195);
                                    S = a(S, x, w, E, d[v + 14], C, 2792965006);
                                    E = a(E, S, x, w, d[v + 15], k, 1236535329);
                                    w = f(w, E, S, x, d[v + 1], L, 4129170786);
                                    x = f(x, w, E, S, d[v + 6], A, 3225465664);
                                    S = f(S, x, w, E, d[v + 11], O, 643717713);
                                    E = f(E, S, x, w, d[v + 0], M, 3921069994);
                                    w = f(w, E, S, x, d[v + 5], L, 3593408605);
                                    x = f(x, w, E, S, d[v + 10], A, 38016083);
                                    S = f(S, x, w, E, d[v + 15], O, 3634488961);
                                    E = f(E, S, x, w, d[v + 4], M, 3889429448);
                                    w = f(w, E, S, x, d[v + 9], L, 568446438);
                                    x = f(x, w, E, S, d[v + 14], A, 3275163606);
                                    S = f(S, x, w, E, d[v + 3], O, 4107603335);
                                    E = f(E, S, x, w, d[v + 8], M, 1163531501);
                                    w = f(w, E, S, x, d[v + 13], L, 2850285829);
                                    x = f(x, w, E, S, d[v + 2], A, 4243563512);
                                    S = f(S, x, w, E, d[v + 7], O, 1735328473);
                                    E = f(E, S, x, w, d[v + 12], M, 2368359562);
                                    w = l(w, E, S, x, d[v + 5], _, 4294588738);
                                    x = l(x, w, E, S, d[v + 8], D, 2272392833);
                                    S = l(S, x, w, E, d[v + 11], P, 1839030562);
                                    E = l(E, S, x, w, d[v + 14], H, 4259657740);
                                    w = l(w, E, S, x, d[v + 1], _, 2763975236);
                                    x = l(x, w, E, S, d[v + 4], D, 1272893353);
                                    S = l(S, x, w, E, d[v + 7], P, 4139469664);
                                    E = l(E, S, x, w, d[v + 10], H, 3200236656);
                                    w = l(w, E, S, x, d[v + 13], _, 681279174);
                                    x = l(x, w, E, S, d[v + 0], D, 3936430074);
                                    S = l(S, x, w, E, d[v + 3], P, 3572445317);
                                    E = l(E, S, x, w, d[v + 6], H, 76029189);
                                    w = l(w, E, S, x, d[v + 9], _, 3654602809);
                                    x = l(x, w, E, S, d[v + 12], D, 3873151461);
                                    S = l(S, x, w, E, d[v + 15], P, 530742520);
                                    E = l(E, S, x, w, d[v + 2], H, 3299628645);
                                    w = c(w, E, S, x, d[v + 0], B, 4096336452);
                                    x = c(x, w, E, S, d[v + 7], j, 1126891415);
                                    S = c(S, x, w, E, d[v + 14], F, 2878612391);
                                    E = c(E, S, x, w, d[v + 5], I, 4237533241);
                                    w = c(w, E, S, x, d[v + 12], B, 1700485571);
                                    x = c(x, w, E, S, d[v + 3], j, 2399980690);
                                    S = c(S, x, w, E, d[v + 10], F, 4293915773);
                                    E = c(E, S, x, w, d[v + 1], I, 2240044497);
                                    w = c(w, E, S, x, d[v + 8], B, 1873313359);
                                    x = c(x, w, E, S, d[v + 15], j, 4264355552);
                                    S = c(S, x, w, E, d[v + 6], F, 2734768916);
                                    E = c(E, S, x, w, d[v + 13], I, 1309151649);
                                    w = c(w, E, S, x, d[v + 4], B, 4149444226);
                                    x = c(x, w, E, S, d[v + 11], j, 3174756917);
                                    S = c(S, x, w, E, d[v + 2], F, 718787259);
                                    E = c(E, S, x, w, d[v + 9], I, 3951481745);
                                    w = r(w, m);
                                    E = r(E, g);
                                    S = r(S, y);
                                    x = r(x, b)
                                }
                                var q = p(w) + p(E) + p(S) + p(x);
                                return q.toLowerCase()
                            }
                            ;
                            return (function($cod, $value) {

                                switch ($cod) {
                                    case '512':
                                    default:
                                        return SHA512($value);
                                        break;
                                    case 'md5':
                                        return md5($value);
                                        break;
                                }

                            });

                        }]);

    app.factory('RestFactory', ['$http','$location', function($http,$location) {
                  
                  
             var url = $location.host();
                 url = 'http://' + url;
            return {
                'get': function($url) {
                    return $http.get($url);

                },
                'save': function($url, $data) {
                    return $http.post($url, $data);
                },
                'update': function($url, $data) {
                    
                   
                    return $http.put( $url, $data);

                },
                'delete': function($url) {
                    return $http({
                        method: 'DELETE',
                        url: $url
                    });
                }

            };

        }]);

    app.factory('Utils', function() {

        return {
            ArrayJoinFiles: function(obj) {

                if (obj.length === 0) {
                    return '';
                }
                var count = 0, str = '';
                for (var i in obj) {
                    if (count > 0) {
                        str += ',';
                    }
                    str += obj[i]['name'];
                    count += 1;
                }

                return str;
            },
            ArraySplitFiles: function(obj) {
                var files = new Array(), pattern = /\,/gi;
                if (obj.length == 0) {
                    return files;
                }
                if (!pattern.test(obj) && obj !== '') {
                    files.push({
                        name: obj
                    });
                    return files;
                }
                var sl = obj.split(','), i = 0, max = sl.length;
                for (; i < max; i += 1) {
                    files.push({
                        name: sl[i]
                    });
                }

                return files;
            }
        };
    });
    
    
    app.factory('cocLoading',function($rootScope){
        var $size = $('#cocLoading').size();
        
                    var markup =  '<div  id="cocLoading" ng-show="isLoadingCocLoading"><div class="ioverlay"></div>' +
                                  '<div class="iloading-img" ></div></div>';
                          $rootScope.isLoadingCocLoading = false;
                   if($size === 0){
                       $(markup).appendTo('body');
                   }       
                          
        return {
            trigger:function(){
                    $('#cocLoading').fadeToggle();
            }
        };
        
    });
   app.factory('DataGridPrepare',function(RestFactory){
       
       
       
   });
})(cocApp, angular);
